<?php

namespace app\adminapi\controller;

use think\facade\Db;

class Report extends Common
{
    public function get()
    {
        $input = $this->_vali([
            'salesactive.default' => '',
        ], "POST");


        $list = Db::name('address')->select();

        $data =[];
        foreach ($list as $key => $value) {
            $data[$key]['name'] = $value['name'];
            if ($input['salesactive'] == 2023){
                $data[$key]['sum'] = Db::name('member')->where('address', $value['id'])->sum('income_one');
            } else {
                $data[$key]['sum'] = Db::name('member')->where('address', $value['id'])->sum('income_tow');
            }
        }

        return json(['status' => 200, 'data' => $data ]);
    }
}